package com.ycsj.goldmedalnewconcept.adapter;

import android.content.Context;
import android.widget.TextView;

import com.squareup.picasso.Picasso;
import com.ycsj.goldmedalnewconcept.R;
import com.ycsj.goldmedalnewconcept.bean.PersonInfo;
import com.ycsj.goldmedalnewconcept.constant.Constant;
import com.ycsj.goldmedalnewconcept.view.RoundImageView;

import java.util.List;


/**
 * 创建日期：2017/11/10  9:57
 * 描述:展示未分组学生的ListView的适配器
 * 作者:张伟
 */

public class StudentLvAdapter extends CommonAdapter<PersonInfo> {
    private Context context;

    public StudentLvAdapter(Context context, List<PersonInfo> datas, int layoutId) {
        super(context, datas, layoutId);
        this.context = context;
    }

    @Override
    public void convert(ViewHolder holder, PersonInfo personInfo) {
        //学生头像
        RoundImageView lvHead = holder.getView(R.id.lv_student);
        //学生姓名
        TextView tvName = holder.getView(R.id.tv_student);

        //学生电话号码
        TextView tvTel = holder.getView(R.id.tv_tel);
        tvTel.setText(personInfo.getTel() + "");

        //设置服务器返回的数据
        tvName.setText(personInfo.getName());
        //设置服务器返回的头像
        if (!personInfo.getIcon().endsWith(".jpg")) {
            Picasso.with(context).load(Constant.SERVER_183+"ycsj_jpxgn/img/" + personInfo.getIcon() + ".jpg").error(R.drawable.defaultimage).into(lvHead);
        } else {
            Picasso.with(context).load(Constant.SERVER_183+"ycsj_jpxgn/img/" + personInfo.getIcon()).error(R.drawable.defaultimage).into(lvHead);
        }
    }
}
